function Tabs(contextPath,divContainer){
	View.apply(this,arguments);
	this.initExtendedDiv();
	this.currentTabObject = null;
	this.subComponents = [];
	
	this.beforeRefresh = function(){
		this.divContainer.className = "xtabs";
		return "";
	};
	
	this.loadComponent = function(tabObject){
		tabObject.className = "tabactive";
		if(this.subComponents&&this.subComponents.length>0){
			for(var i=0;i<this.subComponents.length;i++){
				this.subComponents[i].loadComponent(tabObject.id);
			}
		}
		this.currentTabObject = tabObject;
	};
	
	this.cacheComponent = function(){
		if(this.currentTabObject!==null){
			this.currentTabObject.className = "tabinactive";
			if(this.subComponents&&this.subComponents.length>0){
				for(var i=0;i<this.subComponents.length;i++){
					this.subComponents[i].cacheComponent(this.currentTabObject.id);
				}
			}
		}
	};
	
	this.addTab = function(title){
		if(this.currentTabObject&&title==window["Comm"].trim(this.currentTabObject.innerText)){
			return;
		}
		var spanArray = this.divContainer.getElementsByTagName("SPAN");
		for(var i=0;i<spanArray.length;i++){
			if(window["Comm"].trim(spanArray[i].innerText)==title){
				this.activeTab(spanArray[i]);
				return;
			}
		}
		this.cacheComponent();
		var randomId = window["Comm"].randomString();
		this.divContainer.innerHTML = this.divContainer.innerHTML+'&nbsp;<span id="'+randomId+'" class="tabactive">&nbsp;&nbsp;'+title+'&nbsp;&nbsp;</span>';
		this.currentTabObject = document.getElementById(randomId);
	};
	
	this.activeTab = function(tabObject){
		this.cacheComponent();
		this.loadComponent(tabObject);
	};
	
	this.closeCurTab = function(){
		if(this.currentTabObject){
			var spanArray = this.divContainer.getElementsByTagName("SPAN");
			var nextTabObject = null;
			for(var i=0;i<spanArray.length;i++){
				nextTabObject = spanArray[i];
				if(spanArray[i]==this.currentTabObject){
					if(spanArray[i+1]){
						nextTabObject = spanArray[i+1];
						break;
					}
				}
			}
			this.removeCache(this.currentTabObject.id);
			var spanHtml = this.currentTabObject.outerHTML;
			this.loadComponent(nextTabObject);
			this.divContainer.innerHTML = this.divContainer.innerHTML.replace("&nbsp;"+spanHtml,"");
		}
	};
	
	this.closeAllTab = function(){
		this.divContainer.innerHTML = "";
	};
	
	this.closeOtherTab = function(){
		if(this.currentTabObject){
			this.divContainer.innerHTML = "&nbsp;"+this.currentTabObject.outerHTML;
		}
	};
}

Tabs.prototype = new View();
Tabs.prototype.handleClickEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="SPAN"){
		this.activeTab(handleObject);
		return false;
	}
	return true;
};
Tabs.prototype.handleMouseOverEvent0 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="SPAN"){
		handleObject.style.cursor = "hand";
	}
};
Tabs.prototype.handleMouseUpEvent2 = function(evt){
	var handleObject = evt.srcElement;
	if(handleObject.tagName=="SPAN"){
		this.activeTab(handleObject);
		this.showRightMenu(evt,handleObject);
	}
};
